from Xlib.display import Display
from enum import Enum
from Xlib import XK
import os

DISPLAY = Display()

class Keybindings(Enum):
    LEFT    = set(code for code, _ in DISPLAY.keysym_to_keycodes(XK.XK_Left))
    RIGHT   = set(code for code, _ in DISPLAY.keysym_to_keycodes(XK.XK_Right))
    UP      = set(code for code, _ in DISPLAY.keysym_to_keycodes(XK.XK_Up))
    DOWN    = set(code for code, _ in DISPLAY.keysym_to_keycodes(XK.XK_Down))
    ENTER   = set(code for code, _ in DISPLAY.keysym_to_keycodes(XK.XK_Return))
    X       = set(code for code, _ in DISPLAY.keysym_to_keycodes(XK.XK_X))
    T       = set(code for code, _ in DISPLAY.keysym_to_keycodes(XK.XK_T))
    E       = set(code for code, _ in DISPLAY.keysym_to_keycodes(XK.XK_E))
    R       = set(code for code, _ in DISPLAY.keysym_to_keycodes(XK.XK_R))
    Q       = set(code for code, _ in DISPLAY.keysym_to_keycodes(XK.XK_Q))
    W       = set(code for code, _ in DISPLAY.keysym_to_keycodes(XK.XK_W))

class Config:
    
    keys = {
        Keybindings.LEFT    : "self.move_window('left')",
        Keybindings.RIGHT   : "self.move_window('right')",
        Keybindings.UP      : "self.move_window('up')",
        Keybindings.DOWN    : "self.move_window('down')",
        Keybindings.X       : "self.is_work = False",
        Keybindings.W       : "self.destroy_window(event)",
        Keybindings.ENTER   : "self.run_process('/usr/bin/alacritty')",
        Keybindings.E       : "self.run_process(['/usr/bin/alacritty', '-e', '/home/sdlvt/bowa/scripts/ellie/bin/ellie', '-pC'])",
        Keybindings.R       : "self.current_mode = 'resize'",
    }

    grabbed_keys = [key.value for key in keys.keys()]

    @staticmethod 
    def on_startup():
        os.system("feh --bg-scale ~/bowa/pictures/wallpapers/animecat.jpg")
        os.system("conky &")
        os.system("picom &")



